var TOMCAT = function(){

	var host = "localhost";
	var port = "8080";
	var protocol = "http";
	var resource = "manager";
	var deployedApps = null;
	
	var getTomcatUrl = function(extraResource){
		var url = "http://localhost:8080/manager/list";
		return url;
	}
	
	return {
		
		deployed: function(){
			var deployed = new Array();
			$.ajax({
				url: getTomcatUrl(),
				success: function(data){
					$(data.split("\n")).each(function(){	
						var columns = this.split(":");
						if(columns.length != 4){
							return;	//something wrong witht he line and we don't want it.
						}

						var deployment = {};
						deployment.context = columns[0];
						deployment.state = columns[1];
						deployment.sessions = columns[2];
						deployment.name = columns[3];
						deployment.url = "http://localhost:8080" + deployment.context;
						deployed.push(deployment);
					});	
				},
				async: false
			});
			return deployed;
		},
		
		refresh: function(){
			console.log(this.host);
			getDeployed();
		}
	}
}();